// var path = location.pathname;
// var service = "/" + path.split("/")[1] + "/";

var umanhouse = new Vue(
        {
            el : '#app',
            data : {
                activeName : 'first',
                fileList : [],
                loadingCategory:false,
                loadingUnit :false,
                loadingExportUnit : false,
                loadingImport : false,
                params: {
                    'path': ""
                },
                loadingPrice:false,
                loadingStock:false,
            },
            methods : {

                uploadCategory:function(){
                    return root.goodsInter.goods_import_category_map;
                },

                updateUnit:function(){
                   return root.goodsInter.goods_import_unit_map;
                },

                updateSku:function(){
                  return root.goodsInter.goods_import_skuImport;
                },

                handleRemove : function(file, fileList) {
                },

                handlePreview : function(file) {
                },

                handleExceed : function(files, fileList) {
                },

                beforeRemove : function(file, fileList) {
                },
                handleError : function(err, file, fileList){
                    umanhouse.$message.error(file.name + "导入失败");
                    umanhouse.loadingImport = false;
                },

                handleSuccess: function(response, file, fileList) {
                    if(response.status == "200"){
                        umanhouse.$message.success(file.name + response.message);
                        umanhouse.loadingImport = false;
                    }else{
                        umanhouse.$message.error(file.name + response.message);
                        umanhouse.loadingImport = false;
                    }
                },
                handleError1 : function(err, file, fileList){
                    umanhouse.$message.error(file.name + "导入失败");
                    umanhouse.loadingImport = false;
                },

                handleSuccess1: function(response, file, fileList) {
                    if(response.status == "200"){
                        umanhouse.$message.success(file.name + response.message);
                        umanhouse.loadingImport = false;
                    }else{
                        umanhouse.$message.error(file.name + response.message);
                        umanhouse.loadingImport = false;
                    }
                },

                handleClick : function(tab, event) {
                },
                handleBeforeUpload :function(file){
                    var fileName = file.name;
                    var isWar  = false;
                    var type = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length);
                    if(type == 'xls'|| type == 'xlsx'){
                       isWar=true;
                    }
                    if(!isWar) {
                         umanhouse.$message.error("上传的文件类型只能是'.xls或xlsx' 格式");
                    } else {
                         umanhouse.loadingImport = true;
                    }
                    return isWar;
                },
                handleBeforeUpload1 :function(file){
                    var fileName = file.name;
                    var isWar  = false;
                    var type = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length);
                    if(type == 'xls'|| type == 'xlsx'){
                       isWar=true;
                    }
                    if(!isWar) {
                         umanhouse.$message.error("上传的文件类型只能是'.xls或xlsx' 格式");
                    } else {
                         umanhouse.loadingImport = true;
                    }
                    return isWar;
                },
                synchCategory : function() {
                    umanhouse.$confirm('同步品类数据时，当前获取的数据会覆盖已经存在的数据，是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                          umanhouse.loadingCategory = true;
                          axios.get(root.goodsInter.goods_synchCategory + '?t=' + Math.random())
                          .then(function(res) {
                              if(res.data.status == "200"){
                                  umanhouse.loadingCategory = false;
                                  umanhouse.$message({
                                      type: 'success',
                                      message: '品类同步成功!'
                                    });
                              }else{
                                 umanhouse.loadingCategory = false;
                                 umanhouse.$message({
                                      type: 'error ',
                                      message: '品类同步失败!'
                                    });
                              }
                          })
                      });
                },

                synchUnit : function() {
                    umanhouse.$confirm('同步单位数据时，当前获取的数据会覆盖已经存在的数据，并将，是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                          umanhouse.loadingUnit = true;
                          axios.get(root.goodsInter.goods_synchUnit + '?t=' + Math.random())
                          .then(function(res) {
                              if(res.data.status == "200"){
                                  umanhouse.loadingUnit = false;
                                  umanhouse.$message({
                                      type: 'success',
                                      message: '单位同步成功!'
                                    });
                              }else{
                                 umanhouse.loadingUnit = false;
                                 umanhouse.$message({
                                      type: 'error ',
                                      message: '单位同步失败!'
                                    });
                              }
                          })
                      });
                },

                synchStock: function() {
                    umanhouse.$confirm('同步库存数据时，当前获取的数据会覆盖已经存在的数据，并将，是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                          umanhouse.loadingStock = true;
                          axios.get(root.goodsInter.goods_synchStock + '?t=' + Math.random())
                          .then(function(res) {
                              if(res.status == "200"){
                                  umanhouse.loadingStock = false;
                                  umanhouse.$message({
                                      type: 'success',
                                      message: '库存同步成功!'
                                    });
                              }else{
                                 umanhouse.loadingStock = false;
                                 umanhouse.$message({
                                      type: 'error ',
                                      message: '库存同步失败!'
                                    });
                              }
                          })
                      });
                },

                synchPrice: function() {
                    umanhouse.$confirm('同步价格数据时，当前获取的数据会覆盖已经存在的数据，并将，是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                          umanhouse.loadingPrice = true;
                          axios.get(root.goodsInter.goods_synchPrice + '?t=' + Math.random())
                          .then(function(res) {
                              if(res.status == "200"){
                                  umanhouse.loadingPrice = false;
                                  umanhouse.$message({
                                      type: 'success',
                                      message: '价格同步成功!'
                                    });
                              }else{
                                 umanhouse.loadingPrice = false;
                                 umanhouse.$message({
                                      type: 'error ',
                                      message: '价格同步失败!'
                                    });
                              }
                          })
                      });
                },
                exportUnit : function(){
                    umanhouse.$confirm('是否导出无人仓单位数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                        location.href = root.goodsInter.goods_export_unit + '?t=' + Math.random();
                      });
                },

                exportUnitMap : function(){
                    umanhouse.$confirm('是否导出云采/无人仓单位映射数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                        location.href = root.goodsInter.goods_export_unit_map + '?t=' + Math.random();
                      });
                },
                exportCategory : function(){
                    umanhouse.$confirm('是否导出无人仓品类数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                        location.href = root.goodsInter.goods_export_category + '?t=' + Math.random();
                      });
                },
                exportCategoryMap : function(){
                    umanhouse.$confirm('是否导出云采/无人仓品类映射数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                        location.href = root.goodsInter.goods_export_category_map + '?t=' + Math.random();
                      });
                },

                exportWarehouseMap : function(){
                    umanhouse.$confirm('是否导出云采/无人仓仓库映射数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                        location.href = root.goodsInter.goods_export_warehouse_map + '?t=' + Math.random();
                      });
                },

                exportYunCaiCategory : function(){
                    umanhouse.$confirm('是否导出云采/无人仓品类映射数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                        location.href = root.goodsInter.goods_export_yuncai_category + '?t=' + Math.random();
                      });
                },

                exportYunCaiUnit : function(){
                    umanhouse.$confirm('是否导出云采/无人仓品类映射数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                        location.href = root.goodsInter.goods_export_yuncai_unit + '?t=' + Math.random();
                      });
                },
                exportSku : function(){
                    umanhouse.$confirm('是否导出sku数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                        location.href = root.goodsInter.goods_export_yuncai_sku + '?t=' + Math.random();
                      });
                },
                loadFailData :function(){
                    umanhouse.$confirm('是否下载sku导入的错误数据数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(function() {
                        location.href = root.goodsInter.goods_export_yuncai_error_HOSTu + '?t=' + Math.random();
                      });
                }
            }
        })